package com.cdn.cretry.enums;


import com.cdn.cretry.strategy.DelayStrategy;
import com.cdn.cretry.strategy.ExponentialBackoffStrategy;
import com.cdn.cretry.strategy.FixedDelayStrategy;

/**
 * 蔡定努
 * 2024/06/06 13:34
 */
public enum DelayStrategyType {
    FIXED,
    EXPONENTIAL_BACKOFF;


   public static DelayStrategy getDelayStrategy(DelayStrategyType delayStrategy) {
        switch (delayStrategy) {
            case FIXED:
                return new FixedDelayStrategy();
            case EXPONENTIAL_BACKOFF:
                return new ExponentialBackoffStrategy();
            default:
                throw new IllegalArgumentException("Invalid delay strategy type: " + delayStrategy);
        }
    }

}
